<?php

class rbtActions extends sfActions {
	
	public function executeHide() {
		$user = $this->getUser()->getGuardUser();
		$this->user = $user;
		 if (!$this->getUser()->isAuthenticated()){
			$this->forward(sfConfig::get('sf_login_module'), sfConfig::get('sf_login_action'));
		}
		
		if($this->getRequest()->getMethod() == sfRequest::POST) {
			$rbtIds = $this->getRequestParameter('rbtIds');	
	        try {	
	            if ($rbtIds) {	  
	            	$rbtIds = '(' . $rbtIds . ')';            
                    $connection = Propel::getConnection();
                    $query = "UPDATE ringtone SET rbt_status = 0, last_update_datetime ='". date('Y-m-d H:i:s') 
                            . "' WHERE id IN {$rbtIds}";
                    $statement = $connection->prepareStatement($query);
                    $resultset = $statement->executeQuery();
                    echo "Hide rbts finished!<br/>";                  	                
	            } else {
	                echo "ERROR: rbtIds are missing!<br/>";
	            }
	        } catch (Exception $e) {
	            echo "EXCEPTION: ".$e->getMessage();
	        }
	
	        exit();
		}
	}
}